1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
40 * npapi.h $Revision: 3.48 $
41 * Netscape client plug-in API spec
52 /* Copied from xp_core.h */
53 /* removed #ifdef for hpux defined in /usr/include/model.h */
68 * NO_NSPR_10_SUPPORT disables the inclusion
69 * of obsolete/protypes.h, whose int16, uint16,
70 * int32, and uint32 typedefs conflict with those
73 #ifndef NO_NSPR_10_SUPPORT
74 #define NO_NSPR_10_SUPPORT
77 #include "jri.h" /* Java Runtime Interface */
80 #if defined (__OS2__ ) || defined (OS2)
94 # define _declspec __declspec
100 # endif /* __INTEL__ */
101 #endif /* __MWERKS__ */
104 #include <Carbon/Carbon.h>
106 #define NP_NO_QUICKDRAW
112 # if defined(MOZ_X11)
113 # include <X11/Xlib.h>
114 # include <X11/Xutil.h>
118 /*----------------------------------------------------------------------*/
119 /* Plugin Version Constants */
120 /*----------------------------------------------------------------------*/
122 #define NP_VERSION_MAJOR 0
123 #define NP_VERSION_MINOR 19
126 /* The OS/2 version of Netscape uses RC_DATA to define the
127 mime types, file extensions, etc that are required.
128 Use a vertical bar to separate types, end types with \0.
129 FileVersion and ProductVersion are 32bit ints, all other
130 entries are strings the MUST be terminated wwith a \0.
134 RCDATA NP_INFO_ProductVersion { 1,0,0,1,}
136 RCDATA NP_INFO_MIMEType { "video/x-video|",
138 RCDATA NP_INFO_FileExtents { "avi|",
140 RCDATA NP_INFO_FileOpenName{ "MMOS2 video player(*.avi)|",
141 "MMOS2 Flc/Fli player(*.flc)\0" }
143 RCDATA NP_INFO_FileVersion { 1,0,0,1 }
144 RCDATA NP_INFO_CompanyName { "Netscape Communications\0" }
145 RCDATA NP_INFO_FileDescription { "NPAVI32 Extension DLL\0"
146 RCDATA NP_INFO_InternalName { "NPAVI32\0" )
147 RCDATA NP_INFO_LegalCopyright { "Copyright Netscape Communications \251 1996\0"
148 RCDATA NP_INFO_OriginalFilename { "NVAPI32.DLL" }
149 RCDATA NP_INFO_ProductName { "NPAVI32 Dynamic Link Library\0" }
154 /* RC_DATA types for version info - required */
155 #define NP_INFO_ProductVersion 1
156 #define NP_INFO_MIMEType 2
157 #define NP_INFO_FileOpenName 3
158 #define NP_INFO_FileExtents 4
160 /* RC_DATA types for version info - used if found */
161 #define NP_INFO_FileDescription 5
162 #define NP_INFO_ProductName 6
164 /* RC_DATA types for version info - optional */
165 #define NP_INFO_CompanyName 7
166 #define NP_INFO_FileVersion 8
167 #define NP_INFO_InternalName 9
168 #define NP_INFO_LegalCopyright 10
169 #define NP_INFO_OriginalFilename 11
175 /*----------------------------------------------------------------------*/
176 /* Definition of Basic Types */
177 /*----------------------------------------------------------------------*/
180 typedef unsigned short uint16
;
184 # if defined(__alpha) || defined(__amd64__) || defined(__x86_64__)
185 typedef unsigned int uint32
;
187 typedef unsigned long uint32
;
188 # endif /* __alpha */
192 * AIX defines these in sys/inttypes.h included from sys/types.h
200 # if defined(__alpha) || defined(__amd64__) || defined(__x86_64__)
204 # endif /* __alpha */
220 #ifndef NP_NO_QUICKDRAW
221 NPDrawingModelQuickDraw
= 0,
223 NPDrawingModelCoreGraphics
= 1
227 typedef unsigned char NPBool
;
228 typedef int16 NPError
;
229 typedef int16 NPReason
;
230 typedef char* NPMIMEType
;
234 /*----------------------------------------------------------------------*/
235 /* Structures and definitions */
236 /*----------------------------------------------------------------------*/
239 * NPP is a plug-in's opaque instance handle
243 void* pdata
; /* plug-in private data */
244 void* ndata
; /* netscape private data */
250 typedef struct _NPStream
252 void* pdata
; /* plug-in private data */
253 void* ndata
; /* netscape private data */
258 const char* headers
; /* Response headers from host.
259 * Exists only for >= NPVERS_HAS_RESPONSE_HEADERS.
260 * Used for HTTP only; NULL for non-HTTP.
261 * Available from NPP_NewStream onwards.
262 * Plugin should copy this data before storing it.
263 * Includes HTTP status line and all headers,
264 * preferably verbatim as received from server,
265 * headers formatted as in HTTP ("Header: Value"),
266 * and newlines (\n, NOT \r\n) separating lines.
267 * Terminated by \n\0 (NOT \n\n\0). */
271 typedef struct _NPByteRange
273 int32 offset
; /* negative offset means from the end */
275 struct _NPByteRange
* next
;
279 typedef struct _NPSavedData
286 typedef struct _NPRect
294 typedef struct _NPSize
302 * Unix specific structures and definitions
306 * Callback Structures.
308 * These are used to pass additional platform specific information.
318 } NPAnyCallbackStruct
;
329 } NPSetWindowCallbackStruct
;
335 } NPPrintCallbackStruct
;
341 * The following masks are applied on certain platforms to NPNV and
342 * NPPV selectors that pass around pointers to COM interfaces. Newer
343 * compilers on some platforms may generate vtables that are not
344 * compatible with older compilers. To prevent older plugins from
345 * not understanding a new browser's ABI, these masks change the
346 * values of those selectors on those platforms. To remain backwards
347 * compatible with differenet versions of the browser, plugins can
348 * use these masks to dynamically determine and use the correct C++
349 * ABI that the browser is expecting. This does not apply to Windows
350 * as Microsoft's COM ABI will likely not change.
353 #define NP_ABI_GCC3_MASK 0x10000000
355 * gcc 3.x generated vtables on UNIX and OSX are incompatible with
356 * previous compilers.
358 #if (defined (XP_UNIX) && defined(__GNUC__) && (__GNUC__ >= 3))
359 #define _NP_ABI_MIXIN_FOR_GCC3 NP_ABI_GCC3_MASK
361 #define _NP_ABI_MIXIN_FOR_GCC3 0
365 #define NP_ABI_MACHO_MASK 0x01000000
367 * On OSX, the Mach-O executable format is significantly
368 * different than CFM. In addition to having a different
369 * C++ ABI, it also has has different C calling convention.
370 * You must use glue code when calling between CFM and
371 * Mach-O C functions.
373 #if (defined(TARGET_RT_MAC_MACHO))
374 #define _NP_ABI_MIXIN_FOR_MACHO NP_ABI_MACHO_MASK
376 #define _NP_ABI_MIXIN_FOR_MACHO 0
380 #define NP_ABI_MASK (_NP_ABI_MIXIN_FOR_GCC3 | _NP_ABI_MIXIN_FOR_MACHO)
383 * List of variable names for which NPP_GetValue shall be implemented
386 NPPVpluginNameString
= 1,
387 NPPVpluginDescriptionString
,
388 NPPVpluginWindowBool
,
389 NPPVpluginTransparentBool
,
390 NPPVjavaClass
, /* Not implemented in Mozilla 1.0 */
391 NPPVpluginWindowSize
,
392 NPPVpluginTimerInterval
,
394 NPPVpluginScriptableInstance
= (10 | NP_ABI_MASK
),
395 NPPVpluginScriptableIID
= 11,
397 /* Introduced in Mozilla 0.9.9 */
398 NPPVjavascriptPushCallerBool
= 12,
400 /* Introduced in Mozilla 1.0 */
401 NPPVpluginKeepLibraryInMemory
= 13,
402 NPPVpluginNeedsXEmbed
= 14,
404 /* Get the NPObject for scripting the plugin. Introduced in Firefox
405 * 1.0 (NPAPI minor version 14).
407 NPPVpluginScriptableNPObject
= 15,
409 /* Get the plugin value (as \0-terminated UTF-8 string data) for
410 * form submission if the plugin is part of a form. Use
411 * NPN_MemAlloc() to allocate memory for the string data. Introduced
412 * in Mozilla 1.8b2 (NPAPI minor version 15).
416 /* Used for negotiating drawing models */
417 , NPPVpluginDrawingModel
= 1000
422 * List of variable names for which NPN_GetValue is implemented by Mozilla
428 NPNVjavascriptEnabledBool
,
432 /* 10 and over are available on Mozilla builds starting with 0.9.4 */
433 NPNVserviceManager
= (10 | NP_ABI_MASK
),
434 NPNVDOMElement
= (11 | NP_ABI_MASK
), /* available in Mozilla 1.2 */
435 NPNVDOMWindow
= (12 | NP_ABI_MASK
),
436 NPNVToolkit
= (13 | NP_ABI_MASK
),
437 NPNVSupportsXEmbedBool
= 14,
439 /* Get the NPObject wrapper for the browser window. */
440 NPNVWindowNPObject
= 15,
442 /* Get the NPObject wrapper for the plugins DOM element. */
443 NPNVPluginElementNPObject
= 16,
445 NPNVSupportsWindowless
= 17
448 /* Used for negotiating drawing models */
449 , NPNVpluginDrawingModel
= 1000
450 #ifndef NP_NO_QUICKDRAW
451 , NPNVsupportsQuickDrawBool
= 2000
453 , NPNVsupportsCoreGraphicsBool
= 2001
458 * The type of Tookkit the widgets use
466 * The type of a NPWindow - it specifies the type of the data structure
467 * returned in the window field.
470 NPWindowTypeWindow
= 1,
474 typedef struct _NPWindow
476 void* window
; /* Platform specific window handle */
477 /* OS/2: x - Position of bottom left corner */
478 /* OS/2: y - relative to visible netscape window */
479 int32 x
; /* Position of top left corner relative */
480 int32 y
; /* to a netscape page. */
481 uint32 width
; /* Maximum window size */
483 NPRect clipRect
; /* Clipping rectangle in port coordinates */
484 /* Used by MAC only. */
485 #if defined(XP_UNIX) && !defined(XP_MACOSX)
486 void * ws_info
; /* Platform-dependent additonal data */
488 NPWindowType type
; /* Is this a window or a drawable? */
492 typedef struct _NPFullPrint
494 NPBool pluginPrinted
;/* Set TRUE if plugin handled fullscreen printing */
495 NPBool printOne
; /* TRUE if plugin should print one copy to default printer */
496 void* platformPrint
; /* Platform-specific printing info */
499 typedef struct _NPEmbedPrint
502 void* platformPrint
; /* Platform-specific printing info */
505 typedef struct _NPPrint
507 uint16 mode
; /* NP_FULL or NP_EMBED */
510 NPFullPrint fullPrint
; /* if mode is NP_FULL */
511 NPEmbedPrint embedPrint
; /* if mode is NP_EMBED */
516 typedef EventRecord NPEvent
;
517 #elif defined(XP_WIN)
518 typedef struct _NPEvent
524 #elif defined(XP_OS2)
525 typedef struct _NPEvent
531 #elif defined (XP_UNIX) && defined(MOZ_X11)
532 typedef XEvent NPEvent
;
534 typedef void* NPEvent
;
535 #endif /* XP_MACOSX */
538 typedef void* NPRegion
;
539 #ifndef NP_NO_QUICKDRAW
540 typedef RgnHandle NPQDRegion
;
542 typedef CGPathRef NPCGRegion
;
543 #elif defined(XP_WIN)
544 typedef HRGN NPRegion
;
545 #elif defined(XP_UNIX) && defined(MOZ_X11)
546 typedef Region NPRegion
;
548 typedef void *NPRegion
;
549 #endif /* XP_MACOSX */
553 * Mac-specific structures and definitions.
556 typedef struct NP_Port
558 CGrafPtr port
; /* Grafport */
559 int32 portx
; /* position inside the topmost window */
563 typedef struct NP_CGContext
565 CGContextRef context
;
570 * Non-standard event types that can be passed to HandleEvent
574 NPEventType_GetFocusEvent
= (osEvt
+ 16),
575 NPEventType_LoseFocusEvent
,
576 NPEventType_AdjustCursorEvent
,
577 NPEventType_MenuCommandEvent
,
578 NPEventType_ClippingChangedEvent
,
579 NPEventType_ScrollingBeginsEvent
= 1000,
580 NPEventType_ScrollingEndsEvent
584 #define getFocusEvent (osEvt + 16)
585 #define loseFocusEvent (osEvt + 17)
586 #define adjustCursorEvent (osEvt + 18)
588 #endif /* XP_MACOSX */
591 * Values for mode passed to NPP_New:
597 * Values for stream type passed to NPP_NewStream:
602 #define NP_ASFILEONLY 4
604 #define NP_MAXREADY (((unsigned)(~0)<<1)>>1)
607 /*----------------------------------------------------------------------*/
608 /* Error and Reason Code definitions */
609 /*----------------------------------------------------------------------*/
612 * Values of type NPError:
615 #define NPERR_NO_ERROR (NPERR_BASE + 0)
616 #define NPERR_GENERIC_ERROR (NPERR_BASE + 1)
617 #define NPERR_INVALID_INSTANCE_ERROR (NPERR_BASE + 2)
618 #define NPERR_INVALID_FUNCTABLE_ERROR (NPERR_BASE + 3)
619 #define NPERR_MODULE_LOAD_FAILED_ERROR (NPERR_BASE + 4)
620 #define NPERR_OUT_OF_MEMORY_ERROR (NPERR_BASE + 5)
621 #define NPERR_INVALID_PLUGIN_ERROR (NPERR_BASE + 6)
622 #define NPERR_INVALID_PLUGIN_DIR_ERROR (NPERR_BASE + 7)
623 #define NPERR_INCOMPATIBLE_VERSION_ERROR (NPERR_BASE + 8)
624 #define NPERR_INVALID_PARAM (NPERR_BASE + 9)
625 #define NPERR_INVALID_URL (NPERR_BASE + 10)
626 #define NPERR_FILE_NOT_FOUND (NPERR_BASE + 11)
627 #define NPERR_NO_DATA (NPERR_BASE + 12)
628 #define NPERR_STREAM_NOT_SEEKABLE (NPERR_BASE + 13)
631 * Values of type NPReason:
634 #define NPRES_DONE (NPRES_BASE + 0)
635 #define NPRES_NETWORK_ERR (NPRES_BASE + 1)
636 #define NPRES_USER_BREAK (NPRES_BASE + 2)
639 * Don't use these obsolete error codes any more.
641 #define NP_NOERR NP_NOERR_is_obsolete_use_NPERR_NO_ERROR
642 #define NP_EINVAL NP_EINVAL_is_obsolete_use_NPERR_GENERIC_ERROR
643 #define NP_EABORT NP_EABORT_is_obsolete_use_NPRES_USER_BREAK
646 * Version feature information
648 #define NPVERS_HAS_STREAMOUTPUT 8
649 #define NPVERS_HAS_NOTIFICATION 9
650 #define NPVERS_HAS_LIVECONNECT 9
651 #define NPVERS_WIN16_HAS_LIVECONNECT 9
652 #define NPVERS_68K_HAS_LIVECONNECT 11
653 #define NPVERS_HAS_WINDOWLESS 11
654 #define NPVERS_HAS_XPCONNECT_SCRIPTING 13
655 #define NPVERS_HAS_NPRUNTIME_SCRIPTING 14
656 #define NPVERS_HAS_FORM_VALUES 15
657 #define NPVERS_HAS_POPUPS_ENABLED_STATE 16
658 #define NPVERS_HAS_RESPONSE_HEADERS 17
659 #define NPVERS_HAS_NPOBJECT_ENUM 18
660 #define NPVERS_HAS_PLUGIN_THREAD_ASYNC_CALL 19
662 /*----------------------------------------------------------------------*/
663 /* Function Prototypes */
664 /*----------------------------------------------------------------------*/
666 #if defined(_WINDOWS) && !defined(WIN32)
667 #define NP_LOADDS _loadds
670 #define NP_LOADDS _System
681 * NPP_* functions are provided by the plugin and called by the navigator.
685 char* NPP_GetMIMEDescription(void);
688 NPError NP_LOADDS
NPP_Initialize(void);
689 void NP_LOADDS
NPP_Shutdown(void);
690 NPError NP_LOADDS
NPP_New(NPMIMEType pluginType
, NPP instance
,
691 uint16 mode
, int16 argc
, char* argn
[],
692 char* argv
[], NPSavedData
* saved
);
693 NPError NP_LOADDS
NPP_Destroy(NPP instance
, NPSavedData
** save
);
694 NPError NP_LOADDS
NPP_SetWindow(NPP instance
, NPWindow
* window
);
695 NPError NP_LOADDS
NPP_NewStream(NPP instance
, NPMIMEType type
,
696 NPStream
* stream
, NPBool seekable
,
698 NPError NP_LOADDS
NPP_DestroyStream(NPP instance
, NPStream
* stream
,
700 int32 NP_LOADDS
NPP_WriteReady(NPP instance
, NPStream
* stream
);
701 int32 NP_LOADDS
NPP_Write(NPP instance
, NPStream
* stream
, int32 offset
,
702 int32 len
, void* buffer
);
703 void NP_LOADDS
NPP_StreamAsFile(NPP instance
, NPStream
* stream
,
705 void NP_LOADDS
NPP_Print(NPP instance
, NPPrint
* platformPrint
);
706 int16 NP_LOADDS
NPP_HandleEvent(NPP instance
, void* event
);
707 void NP_LOADDS
NPP_URLNotify(NPP instance
, const char* url
,
708 NPReason reason
, void* notifyData
);
710 jref NP_LOADDS
NPP_GetJavaClass(void);
712 NPError NP_LOADDS
NPP_GetValue(NPP instance
, NPPVariable variable
, void *value
);
713 NPError NP_LOADDS
NPP_SetValue(NPP instance
, NPNVariable variable
, void *value
);
716 * NPN_* functions are provided by the navigator and called by the plugin.
718 void NP_LOADDS
NPN_Version(int* plugin_major
, int* plugin_minor
,
719 int* netscape_major
, int* netscape_minor
);
720 NPError NP_LOADDS
NPN_GetURLNotify(NPP instance
, const char* url
,
721 const char* target
, void* notifyData
);
722 NPError NP_LOADDS
NPN_GetURL(NPP instance
, const char* url
,
724 NPError NP_LOADDS
NPN_PostURLNotify(NPP instance
, const char* url
,
725 const char* target
, uint32 len
,
726 const char* buf
, NPBool file
,
728 NPError NP_LOADDS
NPN_PostURL(NPP instance
, const char* url
,
729 const char* target
, uint32 len
,
730 const char* buf
, NPBool file
);
731 NPError NP_LOADDS
NPN_RequestRead(NPStream
* stream
, NPByteRange
* rangeList
);
732 NPError NP_LOADDS
NPN_NewStream(NPP instance
, NPMIMEType type
,
733 const char* target
, NPStream
** stream
);
734 int32 NP_LOADDS
NPN_Write(NPP instance
, NPStream
* stream
, int32 len
, void* buffer
);
735 NPError NP_LOADDS
NPN_DestroyStream(NPP instance
, NPStream
* stream
, NPReason reason
);
736 void NP_LOADDS
NPN_Status(NPP instance
, const char* message
);
737 const char* NP_LOADDS
NPN_UserAgent(NPP instance
);
738 void* NP_LOADDS
NPN_MemAlloc(uint32 size
);
739 void NP_LOADDS
NPN_MemFree(void* ptr
);
740 uint32 NP_LOADDS
NPN_MemFlush(uint32 size
);
741 void NP_LOADDS
NPN_ReloadPlugins(NPBool reloadPages
);
743 JRIEnv
* NP_LOADDS
NPN_GetJavaEnv(void);
744 jref NP_LOADDS
NPN_GetJavaPeer(NPP instance
);
746 NPError NP_LOADDS
NPN_GetValue(NPP instance
, NPNVariable variable
, void *value
);
747 NPError NP_LOADDS
NPN_SetValue(NPP instance
, NPPVariable variable
, void *value
);
748 void NP_LOADDS
NPN_InvalidateRect(NPP instance
, NPRect
*invalidRect
);
749 void NP_LOADDS
NPN_InvalidateRegion(NPP instance
, NPRegion invalidRegion
);
750 void NP_LOADDS
NPN_ForceRedraw(NPP instance
);
751 void NP_LOADDS
NPN_PushPopupsEnabledState(NPP instance
, NPBool enabled
);
752 void NP_LOADDS
NPN_PopPopupsEnabledState(NPP instance
);
753 void NP_LOADDS
NPN_PluginThreadAsyncCall(NPP instance
,
754 void (*func
) (void *),
758 } /* end extern "C" */
761 #endif /* RC_INVOKED */
766 #endif /* _NPAPI_H_ */